<template>
  <div class="list-container cantSelect">
    <header>
      <div class="userNameBar roundy-10 shadow">
        <span class="userName">{{ user?.userName }}</span>
      </div>
      <div class="userImgBar shadow">
        <img :src="blobToString(user?.userImg)" alt="用户头像">
      </div>
    </header>


    <div class="dropList shadow roundy-10">
      <slot></slot>
    </div>

  </div>
</template>

<script>
export default {
  name: 'UserDropList',
  props: ['user'],
  data() {
    return {
      slice:''
    }
  },
  methods:
  {
    blobToString(img) {
      if (img && typeof img === 'string') {
        var slice = img.slice(0, 11);
      }

      //判断图片格式是否正确
      if (slice == "data:image/") {

        return img;
      }
      var data = "data:image/png;base64," + img;
      return data;
    }
  }
}

</script>

<style scoped>
.list-container {
  transition: all 0.4s 0.4s;

  width: 300px;
  height: 120px;
  /* background-color: rgb(255, 255, 255); */

  margin: 0 0 50px 50px;
  position: relative;

  transform: scale(0.6) translate(200px, -20px);
  z-index: 99;
}
.list-container:hover {
  transition: all 0.4s;

  transform: scale(1);
}

.userNameBar {
  opacity: 0;
  transition: all 0.4s ease 0.2s;

  background-color: rgb(238, 238, 238);
  height: 80px;
  width: 0;
  transform: translate(0px, 50px);
  z-index: 0;

  line-height: 80px;
  padding-left: 100px;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: none;
}


.list-container:hover .userNameBar {
  opacity: 1;
  transition: all 0.4s ease 0.2s;
  background-color: rgba(255, 255, 255, 1);
  width: 90%;
  transform: translate(35px, 50px);
  pointer-events: all;
}

.list-container:hover img {
  transition: all 0.2s;
  background-color: rgba(255, 255, 255, 1);
  filter: contrast(100%);
}


.userName {
  font-weight: bold;
  font-size: 20px;
}

.userImgBar {
  border-radius: 50%;
  height: 120px;
  width: 120px;
  background-color: rgb(108, 159, 255);
  transform: translate(0, -50px);
  z-index: 1;

  overflow: hidden;
}

img {
  transition: all 0.2s;
  margin: 0 auto;
  height: 120px;
  width: 120px;
  z-index: 1;
  filter: contrast(90%);
  -webkit-user-drag: none;
}

.dropList {
  transition: all 0.5s ease;
  opacity: 0;
  /* max-height: 0; */
  width: 250px;
  background-color: rgb(255, 255, 255);
  position: absolute;
  top: 140px;
  left: 50px;
  /* overflow: hidden; */
  padding: 10px;
  padding-top: 5px;
  padding-bottom: 5px;
  box-sizing: border-box;
  pointer-events: none;
}

.list-container:hover .dropList {
  transition: all 0.4s ease 0.4s;
  opacity: 1;
 /*  max-height: 500px; */
 /*  overflow: visible; */
  top: 170px;
  pointer-events: all ;
}


</style>
